package 面试相关;

import jdk.internal.org.objectweb.asm.tree.LdcInsnNode;

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class 游游竖式子 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        List<List<Integer>> lists = new ArrayList<List<Integer>>();
        int i = 0;
        while (i < num){
            ArrayList<Integer> list = new ArrayList();
            list.add(scanner.nextInt());
            list.add(scanner.nextInt());
            lists.add(list);
            i++;
        }
        for(List<Integer> l: lists){
            fun(l);
        }
    }
    public static void fun(List<Integer> list){
        Integer integer = list.get(0);
        Integer integer1 = list.get(1);
        int result = 0;
        while (integer1 != 0){
            int i = integer1 % 10;
            result = result + i * integer;
            integer1 /= 10;
        }
        System.out.println(result);
    }
}
